package com.bwf.coll;

import java.util.ArrayList;
import java.util.List;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/23 10:45
 * @Copyright 博为峰
 */
public class ListDemo {
    public static void main(String[] args) {
//        m1();
//        m2();
//        m3();
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add(1, "c");

        System.out.println(list.get(1));
        System.out.println(list.indexOf("c"));
        System.out.println(list.lastIndexOf("c"));
    }
    //改
    private static void m3() {
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add(1, "c");
        list.set(1,"C");

        System.out.println(list);
    }

    //删
    private static void m2() {
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add(1, "c");
        list.remove(0);
        System.out.println(list);
    }
    //增
    private static void m1() {
        List list = new ArrayList();
        list.add("a");
        list.add("b");
        list.add(1, "c");
        System.out.println(list);
    }
}
